home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / net / etherdefs.h < prev    next >
C/C++ Source or Header  |  1995-02-14  |  3KB  |  102 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1987 Carnegie-Mellon University
  4.  * All rights reserved.  The CMU software License Agreement specifies
  5.  * the terms and conditions for use and redistribution.
  6.  */
  7.  
  8. /*
  9.  * Copyright (c) 1982, 1986 Regents of the University of California.
  10.  * All rights reserved.
  11.  *
  12.  * Redistribution and use in source and binary forms are permitted
  13.  * provided that this notice is preserved and that due credit is given
  14.  * to the University of California at Berkeley. The name of the University
  15.  * may not be used to endorse or promote products derived from this
  16.  * software without specific prior written permission. This software
  17.  * is provided ``as is'' without express or implied warranty.
  18.  *
  19.  * HISTORY
  20.  * 11-Jul-93  Mac Gillon (mgillon) at NeXT
  21.  *    Integrated MULTICAST support
  22.  *
  23.  * 09-Apr-90  Bradley Taylor (btaylor) at NeXT, Inc.
  24.  *    Created. Originally part of <netinet/if_ether.h>.
  25.  */
  26. #ifndef _ETHERDEFS_
  27. #define _ETHERDEFS_
  28.  
  29. /*
  30.  * Ethernet address - 6 octets
  31.  */
  32. #define NUM_EN_ADDR_BYTES    6
  33.  
  34. struct ether_addr {
  35.     u_char    ether_addr_octet[NUM_EN_ADDR_BYTES];
  36. };
  37.  
  38. #define ea_byte    ether_addr_octet
  39.  
  40. typedef struct ether_addr enet_addr_t;
  41.  
  42. /*
  43.  * Structure of a 10Mb/s Ethernet header.
  44.  */
  45. struct    ether_header {
  46.     u_char    ether_dhost[6];
  47.     u_char    ether_shost[6];
  48.     u_short    ether_type;
  49. };
  50.  
  51. typedef struct ether_header ether_header_t;
  52.  
  53. #define IFTYPE_ETHERNET "10MB Ethernet"
  54.  
  55. #define    ETHERTYPE_PUP    0x0200        /* PUP protocol */
  56. #define    ETHERTYPE_IP    0x0800        /* IP protocol */
  57. #define ETHERTYPE_ARP    0x0806        /* Addr. resolution protocol */
  58. #define ETHERTYPE_REVARP 0x8035        /* Reverse ARP (SUN_RPC) */
  59.  
  60. /*
  61.  * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
  62.  * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
  63.  * by an ETHER type (as given above) and then the (variable-length) header.
  64.  */
  65. #define    ETHERTYPE_TRAIL        0x1000        /* Trailer packet */
  66. #define    ETHERTYPE_NTRAILER    16
  67.  
  68.  
  69. #define ETHERHDRSIZE    14
  70. #define    ETHERMTU    1500
  71. #define ETHERMAXPACKET    (ETHERHDRSIZE + ETHERMTU)
  72. #define ETHERMINPACKET    64
  73. #define ETHERCRC    4
  74. #define    ETHERMIN    (ETHERMINPACKET-ETHERCRC-ETHERHDRSIZE)
  75.  
  76. /*
  77.  * Byte and bit in an enet_addr_t defining individual/group destination.
  78.  */
  79. #define EA_GROUP_BYTE    0
  80. #define EA_GROUP_BIT    0x01
  81.  
  82. #ifdef KERNEL
  83. /*
  84.  * Macro to map an IP multicast address to an Ethernet multicast address.
  85.  * The high-order 25 bits of the Ethernet address are statically assigned,
  86.  * and the low-order 23 bits are taken from the low end of the IP address.
  87.  */
  88. #define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr)                \
  89.     /* struct in_addr *ipaddr; */                    \
  90.     /* u_char enaddr[6];       */                    \
  91. {                                    \
  92.     (enaddr)[0] = 0x01;                        \
  93.     (enaddr)[1] = 0x00;                        \
  94.     (enaddr)[2] = 0x5e;                        \
  95.     (enaddr)[3] = ((u_char *)ipaddr)[1] & 0x7f;            \
  96.     (enaddr)[4] = ((u_char *)ipaddr)[2];                \
  97.     (enaddr)[5] = ((u_char *)ipaddr)[3];                \
  98. }
  99. #endif KERNEL
  100.  
  101. #endif /* _ETHERDEFS_ */
  102.